<?php
/***************************************************************************
 *                               monthly.php
 *                            -------------------
 *                       (APU) Automated Pilot Utility
 *   begin                : Monday, Dec 27, 2004
 *   copyright            : (C) 2004 SF Games
 *   email                : techsupport@sf-games.com
 *
 *   This code will create links from discovered htm files in the directory
 *   These files are monthly generated reports
 ***************************************************************************/

	$apus_root_path = '../admin/';
	include($apus_root_path . 'common.php');
	include($apus_root_path . 'config.php');

	$ourSelf = "monthly.php";

	// HTML header
	echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
	echo "<html>\n";
	echo "<head>\n";
	echo "<title>APU Pilot Monthly Reports</title>\n";
	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
	echo "</head>\n";
	echo "<body background=\"http://cybhq.ldldesigns.com/ig/casky2.jpg\" bgproperties=\"fixed\">\n";
	echo "<body>\n";
	echo "<div align=\"center\">\n";
	echo("<font face=\"Verdana\" size=\"4\" color=\"#990000\"><b>(APU) Automated Pilot Utility<br>Monthly Reports</b></font><br><br>\n");
	echo "<p align=\"center\"><font face=\"Verdana\" size=\"1\">Click <a href=\"" .$rosterNavigateTo ."\">here</a> " .$rosterNavigateVerbiage ."</font></p>";

	// Tell what we are doing
	echo("<font face=\"Verdana\" size=\"2\" color=\"#990000\"><b>Monthly and Yearly Totals</b></font><br>\n");
	echo("<font face=\"Verdana\" size=\"2\" color=\"#990000\"><b>Pilots these are the books, records, archieves of KDEN.</b></font><br>\n");
	echo("<font face=\"Verdana\" size=\"2\" color=\"#990000\"><b>Want to know how we did 2 months ago? Select from the links below.</b></font><br><br>\n");

	// Collect the files in this directory
	$dir = "./";
	$dh  = opendir($dir);
	while (false !== ($filename = readdir($dh)))
	{
	   $files[] = $filename;
	}
	sort($files);

	// Begin a 2 column table to display Month/Year and the link
	echo("<table width=\"50%\" border=\"0\" cellspacing=\"3\" cellpadding=\"1\" align=\"center\">\n");

	// Iterate the files
	$fileCount = count($files);
	for ( $x=0; $x < $fileCount; $x++ )
	{
		// If next file is really a file, and it is not ourself
		if ( is_file($files[$x]) && strcmp($files[$x], $ourSelf) != 0 )
		{
			//
			// Rip out the extension junk from around the month/year parts of these file names
			// And use it as the left side of table cell to display the month and year
			//

			$fDate = $files[$x];
			$fDate = str_replace(".htm", "", $fDate);
			$fDate = str_replace("apuMonthly", "", $fDate);

			$month = intval(substr($fDate, 0, 2));
			$year  = substr($fDate, 2, 4);

			echo("<tr>\n");
				echo("<td align=\"right\" width=\"25%\"><b>" .getLongMonthName($month) ." " .$year ."</b></td>\n");
				echo("<td align=\"right\" width=\"75%\"><a href=\"" .$files[$x] ."\">" .$files[$x] ."</a></td>\n");
			echo("</tr>\n");
		}
	}

	// End the table
	echo("</table>\n");

	// HTML footer
	echo("<p><font face=\"Verdana\" size=\"1\" color=\"#999999\">(APU) Automated Pilot Utility. Version " .$APU_VERSION ." Copyright &copy; 2004 <a href=\"http://www.sf-games.com\">SF Games</a></font></p>\n");
	echo "</div>\n";
	echo "</body>\n";
	echo "</html>\n";
?>
